package com.SunSoft.PhoneRemoteControl;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public final class dg
{
  public static String a(String paramString)
  {
    Object localObject = null;
    System.setProperty("http.keepAlive", "false");
    HttpURLConnection localHttpURLConnection = (HttpURLConnection)new URL(paramString).openConnection();
    localHttpURLConnection.setConnectTimeout(5000);
    localHttpURLConnection.setReadTimeout(1000);
    localHttpURLConnection.setRequestMethod("GET");
    paramString = localObject;
    if (localHttpURLConnection.getResponseCode() == 200)
      paramString = new String(a(localHttpURLConnection.getInputStream()), "GB-2312");
    localHttpURLConnection.disconnect();
    return paramString;
  }

  public static String a(String paramString, List paramList)
  {
    try
    {
      paramString = new HttpPost(paramString);
      paramString.setEntity(new UrlEncodedFormEntity(paramList, "UTF-8"));
      paramString = new DefaultHttpClient().execute(paramString);
      if (paramString.getStatusLine().getStatusCode() == 200)
        return EntityUtils.toString(paramString.getEntity());
      return "3";
    }
    catch (java.lang.Exception paramString)
    {
    }
    return "0";
  }

  private static byte[] a(InputStream paramInputStream)
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte = new byte[1024];
    while (true)
    {
      int i = paramInputStream.read(arrayOfByte);
      if (i == -1)
      {
        paramInputStream.close();
        return localByteArrayOutputStream.toByteArray();
      }
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
    }
  }
}